package com.jyxd.web.data.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Objects;

@Data
@ApiModel("返回数据")
public class HttpResult {

    @ApiModelProperty(name = "返回值code")
    private Integer code;

    @ApiModelProperty(name = "返回值数据")
    private Object data;

    @ApiModelProperty(name = "请求返回信息")
    private String msg;

    @ApiModelProperty("分页总页数")
    private Integer totalCount;

    @ApiModelProperty("分页总页数")
    private Integer start;

    public HttpResult (Integer code, Object data, Integer start, Integer totalCount, String msg) {
        this.code = code;
        this.data = data;
        this.start = start;
        this.totalCount = totalCount;
        this.msg = msg;
    }

    public HttpResult (Integer code, Object data, Integer totalCount, String msg) {
        this.code = code;
        this.data = data;
        this.totalCount = totalCount;
        this.msg = msg;
    }

    public HttpResult(Integer code, Object data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    public HttpResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public HttpResult(Integer code) {
        this.code = code;
        if (Objects.equals(code, 200)) {
            this.msg = "数据查询成功";
        }
    }

}
